// pages/select-city/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    indexList: [
      {
        alpha: '定',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      }, 
      {
        alpha: '热',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'A',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'B',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'C',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'D',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'E',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'F',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'G',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'H',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'I',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'J',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'K',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'L',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'M',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'N',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'O',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'P',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'Q',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'R',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'S',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'T',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'U',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'V',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'W',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'X',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'Y',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
      {
        alpha: 'Z',
        child: [
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
          { id: 0, name: '合肥市' },
        ]
      },
    ],
    hotCities: [
      { id: 1, name: '合肥市' },
      { id: 1, name: '滁州市' },
      { id: 1, name: '蚌埠市' },
      { id: 1, name: '池州市' },
      { id: 1, name: '铜陵市' },
      { id: 1, name: '马鞍山市' },
      { id: 1, name: '安庆市' },
      { id: 1, name: '六安市' },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  jump(e) {
    const word = e.currentTarget.dataset.word
    const query = wx.createSelectorQuery()
    query.select('.scrollview')
      .node()
      .exec((res) => {
        const scrollView = res[0].node;
        if (word == '定') {
          scrollView.scrollIntoView('.city')
        } else if (word == '热') {
          scrollView.scrollIntoView('.hot')
        } else {
          scrollView.scrollIntoView(`.${word}`)
        }
      })
  },
  selectCity (e) {
    const { item } = e.currentTarget.dataset;
    console.log(item, 'aaaa');
    this.jump({
      currentTarget: { dataset: { word: item.name } }
    });
  },
  search (e) {
    console.log(e);
    this.jump({
      currentTarget: { dataset: { word: e.detail.value } }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})